package forum.client.ui.events;

import forum.client.ui.ForumTreeHandler;
import java.awt.Component;

/**
 * @author Tomer Heber
 *
 */
public class ForumTreeErrorEvent implements ForumTreeEvent {

	/**
	 * The error message to show the user in the GUI.
	 */
	private String m_errorMessage;
        private Component comp = null;

        public ForumTreeErrorEvent(String errorMessage){
            	m_errorMessage = errorMessage;
                comp = null;
        }
	public ForumTreeErrorEvent(String errorMessage, Component c) {
		m_errorMessage = errorMessage;
                comp = c;
	}

	/* (non-Javadoc)
	 * @see forumtree.contol.ForumTreeEvent#respondToEvent(forumtree.ForumTree)
	 */
	@Override
	public void respondToEvent(ForumTreeHandler handler) {
            if(comp != null){
		handler.notifyError(m_errorMessage, comp);
            }else{
                handler.notifyError(m_errorMessage);
            }
	}

        public void respondToEvent(ForumTreeHandler handler, Component c) {
		handler.notifyError(m_errorMessage,c);
	}

}
